import { controller, all, post,get } from "../decorator/router";
import config from "../config";
import { middlewareWechat } from "../wechat-lib/middleware";
import {signture,redirect,oauth} from "../controllers/wechat"
import {getWechat} from "../wechat"
const client = getWechat();
@controller("")
class Wechat {
  constructor() {}
  @all("/wechat-hear")
  async wechatHear(ctx, next) {
    const middle = middlewareWechat(config);
    await middle(ctx, next);
  }

  @get("/wechat-signture")
  async wechatSignture(ctx,next){
    const res = await signture(ctx,next);
    // console.log(res);
  }

  @get("/wechat-redirect")
  async wechatRedirect(ctx,next){
    const res = await redirect(ctx,next);
  }

  @get("/oauth")
  async wechatOauth(ctx,next){
    const res = await oauth(ctx,next);
    // console.log(res);
  }

  @get("/tag/test")
  async adminMaterial(ctx, next) {
    const createTag = await client.handle("getMenu");
    console.log(createTag);
    ctx.body = 'yes';
  }
}
